#include <bits/stdc++.h>
using namespace std;
int n,m,l,v,pd,sum,rec,reci,leg,mid,maxq,pp;
int le[100005],ri[100005],limi[100005],marki[100005],banned[100005];
void dfs(int k,int qu)
{
	if(k==m)
	{
		/*if(qu==5)
		{
			for(int i=0;i<10;i++)cout<<banned[i]<<" ";
			cout<<endl;
		}*/
		maxq=max(maxq,qu);
		return;
	}
	banned[k]=1;
	pd=1;
	for(int i=0;i<leg;i++)
	{
		pp=0;
		for(int j=0;j<m;j++)
		{
			mid=j;
			if(le[marki[i]]<=limi[mid] && limi[mid]<=ri[marki[i]] && !banned[mid]){pp=1;break;}
		}
		if(!pp){pd=0;break;}
	}
	//if(k==7)cout<<pd<<endl;
	if(pd)
	{
		dfs(k+1,qu+1);
	}
	banned[k]=0;
	dfs(k+1,qu);
	return;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;cin>>t;
	while(t--)
	{
		cin>>n>>m>>l>>v;
		pd=1;sum=0;
		for(int i=0;i<n;i++)
		{
			int d,vv,a;//cin>>d>>vv>>a;
			scanf("%d%d%d",&d,&vv,&a);
			if(a<0)
			{
				pd=0;
				if(vv<=v)le[i]=-1;
				else
				{
					le[i]=d;
					ri[i]=d+int(ceil((1.0*v*v-1.0*vv*vv)/(2.0*a)))-1;
				}
			}
			if(a==0)
			{
				if(vv>v)
				{
					le[i]=d;
					ri[i]=l;
				}
				else le[i]=-1;
			}
			if(a>0)
			{
				if(vv>v)
				{
					le[i]=d;
					ri[i]=l;
				}
				else
				{
					le[i]=d+int((1.0*v*v-1.0*vv*vv)/(2.0*a))+1;
					if(le[i]>l)le[i]=-1;
					else ri[i]=l;
				}
				//cout<<le[i]<<" "<<ri[i]<<endl;
			}
		}
		for(int i=0;i<m;i++)scanf("%d",&limi[i]);//cin>>limi[i];
		if(pd)
		{
			for(int i=0;i<n;i++)
			{
				if(le[i]!=-1 && le[i]<=limi[m-1])sum++;
			}
			cout<<sum<<" ";
			if(sum==0)cout<<m<<endl;
			else cout<<m-1<<endl;
		}
		else 
		{
			rec=0;leg=0;maxq=0;
			for(int i=0;i<n;i++)
			{
				if(le[i]!=-1 && ri[i]==l && le[i]<=limi[m-1])
				{
					sum++;
					if(le[i]>rec)
					{
						rec=le[i];reci=i;
					}
				}
				else if(le[i]!=-1)
				{
					//cout<<le[i]<<" "<<ri[i]<<endl;
					pd=0;
					int lef=0,rig=m-1;
					while(lef<=rig)
					{
						mid=(lef+rig)/2;
						if(le[i]<=limi[mid] && limi[mid]<=ri[i]){pd=1;break;}
						if(le[i]>limi[mid])lef=mid+1;
						else rig=mid-1;
					}
					if(pd)
					{
						sum++;
						marki[leg]=i;leg++;
					}
				}
			}
			if(rec!=-0)
			{marki[leg]=reci;leg++;}
			//cout<<leg<<endl;
			//for(int i=0;i<leg;i++)cout<<le[marki[i]]<<" "<<ri[marki[i]]<<endl;
			//cout<<endl;
			
			cout<<sum<<" ";
			memset(banned,0,sizeof(banned));
			dfs(0,0);
			cout<<maxq<<endl;
		}
	}
	return 0;
}
